<template>
  <el-dialog
    :title="!dataForm.id ? '详情' : '详情'"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-form
      :model="dataForm"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="160px"
    >
      <el-form-item label="金额：">
        {{ dataForm.money }}
      </el-form-item>
      <el-form-item label="下单时间：">
        {{ dataForm.cjTime }}
      </el-form-item>
      <el-form-item label="类型：">
       <div v-if="dataForm.type  == 1"> 酒店 </div>
       <div v-if="dataForm.type  == 2"> 民宿 </div>
       <div v-if="dataForm.type  == 3"> 文创 </div>
       <div v-if="dataForm.type  == 4"> 餐饮 </div>
       <div v-if="dataForm.type  == 5"> 票务 </div>
      </el-form-item>
      <el-form-item label="状态：">
        <div v-if="dataForm.zt == 0">未支付</div>
        <div v-if="dataForm.zt == 1">已付款</div>
        <div v-if="dataForm.zt == 1 && dataForm.type == 1 ">确认中</div>
        <div v-if="dataForm.zt == 1 && dataForm.type == 3">待发货</div>
        <div v-if="dataForm.zt == 2">取消</div>
        <div v-if="dataForm.zt == 3">用户申请退款</div>
        <div v-if="dataForm.zt == 4">已完成 </div>
        <div v-if="dataForm.zt == 5">评价完成</div>
        <div v-if="dataForm.zt == 6">确定完成</div>
        <div v-if="dataForm.zt == 7">退款完成 </div>
        <div v-if="dataForm.zt == 8">商家申请退款</div>
        <div v-if="dataForm.zt == 9">已发货</div>
        <div v-if="dataForm.zt == 11">已同意退款</div>
        <div v-if="dataForm.zt == 12">已出票</div>
      </el-form-item>
      <el-form-item label="订单编号：">
        {{ dataForm.number }}
      </el-form-item>
      <el-form-item label="物流单号：" v-if="dataForm.type == 3">
        {{ dataForm.wldh }}
      </el-form-item>
      <el-form-item label="票付通订单号：" v-if="dataForm.type == 5">
        {{ dataForm.uuordernum }}
      </el-form-item>
      <el-form-item label="留言：">
        {{ dataForm.text }}
      </el-form-item>
      <el-form-item label="电话：">
        {{ dataForm.phone }}
      </el-form-item>
      <el-form-item label="微信交易号：">
        {{ dataForm.wxTransaction}}
      </el-form-item>
      <el-form-item label="实际入驻时间：" v-if="dataForm.type == 1 || dataForm.type == 2">
        {{ dataForm.sjrzTime}}
      </el-form-item>
      <el-form-item label="实际离店时间："  v-if="dataForm.type == 1 || dataForm.type == 2">
        {{ dataForm.lkTime}}
      </el-form-item>
      <el-form-item label="载止时间注:餐饮用：" v-if="dataForm.type == 4">
        {{ dataForm.jzsj }}
      </el-form-item>
      <el-form-item label="收货地址：" v-if="dataForm.type == 3">
        {{ dataForm.shdz }}
      </el-form-item>
      <el-form-item label="数量：">
        {{ dataForm.sl }}
      </el-form-item>
      <el-form-item label="预计到店时间：" v-if="dataForm.type == 1 || dataForm.type == 2">
        {{ dataForm.yjddTime }}
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      imageUrl: '',
      visible: false,
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false,
      dataForm: {
        id: "",
        title: "",
        zj: "",
        dj: "",
        images: "",
        sl: "",
        headPhoto: "",
        status: "",
      },
      options: [
        {
          value: 0,
          label: "上架",
        },
        {
          value: 1,
          label: "下架",
        },
      ],
    };
  },
  methods: {
    init(id) {
      this.dataForm.id = id || "";
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].resetFields();
        if (this.dataForm.id) {
          this.$http({
            url: this.$http.adornUrl(
              `sys/order/queryByid?id=${this.dataForm.id}`
            ),
            method: "get",
            params: this.$http.adornParams(),
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataForm= data.order;
            }
          });
        }
      });
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`sys/creativegoods/update`),
              method: "post",
              params: this.$http.adornParams({
                id: this.dataForm.id,
                title: this.dataForm.title,
                zj: this.dataForm.zj,
                dj: this.dataForm.dj,
                images: this.dataForm.images,
                sl: this.dataForm.sl,
                headPhoto: this.dataForm.headPhoto,
                status: this.dataForm.status
              }),
            }).then(({ data }) => {
              if (data && data.code === 0) {
                this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                    this.$emit("refreshDataList");
                  },
                });
              } else {
                this.$message.error(data.msg);
              }
            });
          } else {
            this.$http({
              url: this.$http.adornUrl(`sys/creativegoods/save`),
              method: "post",
              params: this.$http.adornParams({
                title: this.dataForm.title,
                zj: this.dataForm.zj,
                dj: this.dataForm.dj,
                images: this.dataForm.images,
                sl: this.dataForm.sl,
                headPhoto: this.dataForm.headPhoto,
                status: this.dataForm.status,
              }),
            }).then(({ data }) => {
              if (data && data.code === 0) {
                this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                    this.$emit("refreshDataList");
                  },
                });
              } else {
                this.$message.error(data.msg);
              }
            });
          }
        }
      });
    },
  },
};
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>